# syntax=docker/dockerfile:1.4
FROM maven:3-amazoncorretto-17-al2023 as builder
WORKDIR /build
COPY . /build
#RUN mvn clean package -X -D skipTests -pl ruoyi-extend/ruoyi-monitor-admin -am -P dev,dist -s settings.xml
# 需要启用Docker的BuildKit功能
RUN --mount=type=cache,id=m2_cache,sharing=locked,target=/root/.m2 mvn clean package -X -D skipTests -pl ruoyi-extend/ruoyi-powerjob-server -am -P dev,dist -s settings.xml
FROM amazoncorretto:17-alpine3.19
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk add --no-cache fontconfig ttf-freefont
RUN addgroup -g 9528 app && adduser -u 9528 -G app -h /app -s /bin/sh -D app
USER app
WORKDIR /app
COPY --from=builder --chown=app:app /build/ruoyi-extend/ruoyi-powerjob-server/dist/app.jar .
ENTRYPOINT ["java", "-jar", "app.jar", "-server", "-Djava.awt.headless=true", "-Djava.security.egd=file:/dev/./urandom", "-Dfile.encoding=UTF-8", "-Duser.timezone=Asia/Shanghai"]
